<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Models\WechatSet;

class WechatSetController extends BaseController
{
    public function __construct(WechatSet $wechatSet)
    {
        parent::__construct();
        $this->model = $wechatSet;
    }

    public function getIndex()
    {
        $data = $this->model->getOne();
        return view('admin.wechatset.edit', compact('data'));
    }

    public function postUpdate(Request $request)
    {
        $where['id'] = 2;
        $data = $request->except('_token');
        $res = $this->model->updateOrCreate($where, $data);
        if(!$res)
        {
            return redirect()->back()->with('status', '提交失败！ :(');
        }
        $key = 'yun_wechat_set';
        $this->model->delMc($key);
        return redirect()->back()->with('status', '提交成功！ :)');
    }
}
